package com.ruitu.health_1.mvp.model;

import com.ruitu.arad.base.BaseModel;
import com.ruitu.health_1.dao.bean.OrderDetail;
import com.ruitu.health_1.dao.bean.Pay;
import com.ruitu.health_1.dao.bean.StoreOrderItemList;
import com.ruitu.health_1.dao.bean.SubCommit;
import com.ruitu.health_1.dao.http.APIRetrofit;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.PageModel2;
import com.ruitu.router_module.bean.cart.CouponList;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;

public class OrderModel {
    public static class GenerateM extends BaseModel {
        public Observable<BaseResult2<Pay>> generate(RequestBody body) {
            return APIRetrofit.getDefault().generateOrder(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<SubCommit>> subOrder(RequestBody body) {
            return APIRetrofit.getDefault().subOrder(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<List<CouponList>>> getCanUseCoupon(String cartItemId, String memberId) {
            return APIRetrofit.getDefault().getCanUseCoupon(cartItemId, memberId)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> lock(RequestBody body) {
            return APIRetrofit.getDefault().lock(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> unLock(RequestBody body) {
            return APIRetrofit.getDefault().unLock(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<String>> memberGoldLock(RequestBody body) {
            return APIRetrofit.getDefault().memberGoldLock(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<String>> memberGoldUnLock(RequestBody body) {
            return APIRetrofit.getDefault().memberGoldUnLock(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

    }

    public static class OrderM extends BaseModel {
        public Observable<BaseResult2<PageModel2<StoreOrderItemList>>> orderList(int pageNum, int pageSize, String memberId, String status) {
            return APIRetrofit.getDefault().orderList(pageNum, pageSize, memberId, status)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2> confirmReceipt(RequestBody body) {
            return APIRetrofit.getDefault().confirmReceipt(body)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2> cancelOrder(RequestBody body) {
            return APIRetrofit.getDefault().cancelOrder(body)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2<OrderDetail>> getOrder(String memberId, String orderId) {
            return APIRetrofit.getDefault().getOrder(memberId, orderId)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2<OrderDetail>> getOrderItem(String memberId, String orderItemId) {
            return APIRetrofit.getDefault().getOrderItem(memberId, orderItemId)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2<Pay>> payOldorder(RequestBody body) {
            return APIRetrofit.getDefault().payOldorder(body)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

    }

    public static class PayOrderM extends BaseModel {
        public Observable<BaseResult2> balancePay(RequestBody body) {
            return APIRetrofit.getDefault().balancePay(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }
    }

    public static class OrderDetailsM extends BaseModel {

    }
}
